package zipsvc

import (
	"fmt"
	"gmap-backend/internal/config"
	"gmap-backend/internal/server/vo"
	"gmap-backend/internal/util/compressutil"
	"os"
)

// ZipDir 对指定目录创建压缩文件，指定的目录和保存位置必须是绝对路径
func ZipDir(appConfig *config.AppConfig, req *vo.ZipDirReq, bins [][]byte) {
	stat, err := os.Stat(req.SrcDir)
	if nil != err || !stat.IsDir() {
		panic(fmt.Sprintf("指定的目录不存在：\r\n%s", req.SrcDir))
	}
	if e := compressutil.ZipDir(req.SrcDir, req.DestZipFullpath, req.ContainsRootDir); nil != e {
		panic(fmt.Sprintf("创建压缩文件时出现错误：\r\n%s", req.DestZipFullpath))
	}
}
